Imports System
Imports System.Drawing
Imports System.EventArgs
Imports System.Windows.Forms.KeyEventArgs
Imports System.Windows.Forms.KeyPressEventArgs

Namespace xpComponent.Form
    Public NotInheritable Class MenuEventHandle
        Public Shared useImage As System.Drawing.Image = Nothing
        Public Shared userFont As System.Drawing.Font

        Public Shared Sub DrawItem(ByVal sender As Object, ByVal e As System.Windows.Forms.DrawItemEventArgs)
            Dim anyMenu As System.Windows.Forms.MenuItem = CType(sender, System.Windows.Forms.MenuItem)
            e.DrawBackground()
            e.Graphics.DrawImage(useImage, e.Bounds.Left + 2, e.Bounds.Top + 2)
            e.Graphics.DrawString(anyMenu.Text, userFont, New System.Drawing.SolidBrush(System.Drawing.Color.Black), e.Bounds.Left + 20, e.Bounds.Top + 5)
        End Sub

        Public Shared Sub MeasureItem(ByVal sender As Object, ByVal e As System.Windows.Forms.MeasureItemEventArgs)
            Dim anyMenu As System.Windows.Forms.MenuItem = CType(sender, System.Windows.Forms.MenuItem)
            e.ItemHeight = e.Graphics.MeasureString(anyMenu.Text, userFont).Height + 3
            e.ItemWidth = e.Graphics.MeasureString(anyMenu.Text, userFont).Width + 5
        End Sub
    End Class
End Namespace